<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link type="text/css" href="../css/Info.css" rel="stylesheet" >
<link type="text/css" href="../js/jDialog/jDialog.css" rel="stylesheet" >
<script type="text/javascript" src="../js/jDialog/jquery.dialog.js"></script>
<script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../js/form/jquery.form.js"></script>
<title>修改密码</title>
<script type="text/javascript">
var userObj;
var userId;
$(document).ready(function() {
	userObj =window.userObj;
	userId = userObj[0].userId;
	$("#userDTO\\.userId").val(userId);
});
var oldPwd = userObj[0].userPwd;
$.modify = function(){
	var dialog;
	if($("#ordPwd").val()!=oldPwd){
		dialog = jDialog.tip('原密码填写错误，请重新填写',{
			target : $('#ordPwd'),
   			position : 'right-top',
   			trianglePosFromStart :0,
			autoClose : 1000,
			offset : {
        		top :-20,
				left:10,
				right:0,
				bottom:0
   			}
		});
	}else{
		if($("#newPwd").val() == ""){
			dialog = jDialog.tip('密码不能为空，请重新填写',{
				target : $('#newPwd'),
	   			position : 'right-top',
	   			trianglePosFromStart :0,
				autoClose : 1000,
				offset : {
	        		top :-20,
					left:10,
					right:0,
					bottom:0
	   			}
			});
		}else if($("#newPwd").val()!=$("#userDTO\\.userPwd").val()){
			dialog = jDialog.tip('两次密码不一致，请重新填写',{
				target : $('#userDTO\\.userPwd'),
	   			position : 'right-top',
	   			trianglePosFromStart :0,
				autoClose : 1000,
				offset : {
	        		top :-20,
					left:10,
					right:0,
					bottom:0
	   			}
			});
		}else{
			var options = {
					type : 'post',
					dataType : 'text',
					url : '../user/modifyUserPwd.action',
					success : function(msg) {
						if(msg==1){
							dialog = jDialog.alert('密码修改成功，请重新登录！',{},{
								showShadow: false,// 不显示对话框阴影
								buttonAlign : 'center',
								events : {
									show : function(evt){
										var dlg = evt.data.dialog;
									},
									close : function(evt){
										var dlg = evt.data.dialog;
										$.ajax({
											type : 'post',
											dataType : 'text',
											url : '../user/logoutCheck.action',
											data : {
												"userDTO.userId":userId
											},
											success : function(msg) {
												window.top.location.href = "../user_login.html";
											},
											error : function(msg) {
												window.top.location.href = "../user_login.html";
											}
										});
									},
									enterKey : function(evt){
										alert('enter key pressed!');
									},
									escKey : function(evt){
										evt.data.dialog.close();
									}
								}
							  });
						}
						else{
							dialog = jDialog.dialog({
								title : '提示信息',
								content : '密码修改失败！'
							});
						}
					}
				};
				$("#modifyForm").ajaxSubmit(options);
		}
	}
}
</script>
</head>
<body>
<div class="mineInfo">
<span id="info1">修改密码&nbsp;MODIFY</span>
<hr style="height:1px;border:none;border-top:1px solid #555555;" />
</div>
<div id="fromContent">
<form name="modifyForm" id="modifyForm" method="post">
<ul class="nopoint2">
<li><label>原密码：</label>&nbsp;&nbsp;&nbsp;<input type="password" id="ordPwd" name="ordPwd"/></li>
<li><label>新密码：</label>&nbsp;&nbsp;&nbsp;<input type="password" id="newPwd" name="newPwd"/></li>
<li><label>确认密码：</label><input type="password" id="userDTO.userPwd" name="userDTO.userPwd"/></li>
<li><input type="button" value="修  改" onclick="$.modify()" style="margin-left:20%;background:#6C6C6C;"/></li>
</ul>
<input type="hidden" id="userDTO.userId" name="userDTO.userId">
</form>
</div >
</body>
</html>